//
//  ViewController.m
//  citicbank
//
//  Created by chen on 17/1/19.
//  Copyright © 2017年 chen. All rights reserved.
//


#import "ViewController.h"
#import "ZZiflyTool.h"

@interface ViewController ()


@end

@implementation ViewController

- (void)viewDidLoad {
    
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)onClick:(id)sender{
     NSMutableString *song=[[NSMutableString alloc] init];
    [[ZZiflyTool shareTool] startRecognizer:^(IFlySpeechError *error, NSString *result) {
        
        
        if (error) {
            
            [self showMes:error.errorDesc];
            
            return;
        }
        [song appendString:result];
        if (song.length <= 0) {
            NSString *str = @"没听到您说啥";
            [self showMes:str];
        }else{
            [self.wordName setText:song];
        }
        
        
    }];
}
//- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
//    
//    [[ZZiflyTool shareTool] startRecognizer:^(IFlySpeechError *error, NSString *result) {
//        
//        
//        if (error) {
//            
//            [self showMes:error.errorDesc];
//            
//            return;
//        }
//        
//        NSString *str =  result.length ? result:@"没听到你说啥";
//        
//        [self showMes:str];
//        
//    }];
//    
//}

- (void)showMes:(NSString *)message{
    
    
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:message message:nil preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *ac = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        [vc dismissViewControllerAnimated:YES completion:nil];
    }];
    
    [vc addAction:ac];
    
    [self presentViewController:vc animated:YES completion:nil];
    
}

//- (IBAction)onClick:(id)sender {
//}
@end
